package com.jvxb.manage.livable.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.jvxb.common.base.entity.WorkResult;
import com.jvxb.common.utils.WorkTaskUtil;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jvxb.manage.livable.service.AssetsAgentHostService;
import com.jvxb.manage.livable.mapper.AssetsAgentHostMapper;
import com.jvxb.manage.livable.entity.AssetsAgentHost;

import java.util.Map;

/**
 * @author jvxb
 * @since 2022-01-05
 */
@Service
public class AssetsAgentHostServiceImpl extends ServiceImpl<AssetsAgentHostMapper, AssetsAgentHost> implements AssetsAgentHostService {

    @Override
    public void checkInitStatu(AssetsAgentHost assetsAgentHost) {
        WorkResult versionResult = WorkTaskUtil.getVersion(assetsAgentHost.getHost());
        if (versionResult.getCode().equals(200) && versionResult.getData() != null) {
            String version = versionResult.getData();
            assetsAgentHost.setInitVersion(version);
            assetsAgentHost.setIsInit(AssetsAgentHost.INIT_STATU);
            updateById(assetsAgentHost);
        }

    }
}
